LinearInterpFloatFloat Function

private function LinearInterpFloatFloat(x1, x2, y1, y2, x) result(y)

calculates linear interpolation between real numbers.

Arguments

Type IntentOptional Attributes Name
real(kind=float), intent(in) :: x1
real(kind=float), intent(in) :: x2
real(kind=float), intent(in) :: y1
real(kind=float), intent(in) :: y2
real(kind=float), intent(in) :: x

Return Value real(kind=float)


Source Code

FUNCTION LinearInterpFloatFloat  &
  ( x1, x2, y1, y2, x )     &
RESULT (y)

IMPLICIT NONE

! Function arguments
! Scalar arguments with intent(in):
REAL (KIND = float), INTENT (IN) :: x1, x2, y1, y2, x

! Scalar arguments with intent (out):
REAL (KIND = float) :: y

!------------end of declaration------------------------------------------------

y = y1 + ( y2 - y1 ) / ( x2 - x1 ) * ( x - x1 )

END FUNCTION LinearInterpFloatFloat